package com.team11.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.team11.server.mapper.PInformationMapper;
import com.team11.server.pojo.PInformation;
import com.team11.server.service.IPInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author pjc
 * @since 2021-06-15
 */

@Service
public class PInformationServiceImpl extends ServiceImpl<PInformationMapper, PInformation> implements IPInformationService {

    @Resource
    private PInformationMapper pInformationMapper;

    /**
     * 获取小组名称
     *
     * @return
     */
    @Override
    public Object getPName() {
        List<PInformation> items = pInformationMapper.selectList(null);
        List<String> list = items.stream().map(PInformation::getPName).collect(Collectors.toList());
        return list;
    }

    @Override
    public Object getProject() {
        List<Map<String, Object>> project = pInformationMapper.selectMaps(new QueryWrapper<PInformation>().select("p_id","p_name"));
        return project;
    }
}